/*
 * RelatorioAGMPanel.java
 *
 * Created on 19 de Abril de 2009, 13:35
 */

package br.uece.comp.paa.gui;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JTextPane;

import br.uece.comp.paa.entity.GeradorArvoreMinima;
import br.uece.comp.paa.gui.action.ExibirAGM;
import br.uece.comp.paa.gui.action.GerarRelatorioAction;

/**
 *
 * @author  juliano
 */
public class RelatorioAGMPanel extends javax.swing.JPanel {

	private static final long serialVersionUID = 1L;

	/** Creates new form RelatorioAGMPanel */
    public RelatorioAGMPanel() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jTextPane1 = new javax.swing.JTextPane();
        jLabel1 = new javax.swing.JLabel();
        labelAlgoritmo = new javax.swing.JLabel();
        comAlgoritmo = new javax.swing.JComboBox();
        labelGrauMaximo = new javax.swing.JLabel();
        labelQtdArvores = new javax.swing.JLabel();
        labelCustoMaximo = new javax.swing.JLabel();
        tfGrauMaximo = new javax.swing.JTextField();
        tdQtdArvores = new javax.swing.JTextField();
        tfCustoMaximo = new javax.swing.JTextField();
        botaoGerar = new javax.swing.JButton();
        labelResultado = new javax.swing.JLabel();
        botaoExibir = new javax.swing.JButton();

        setPreferredSize(new java.awt.Dimension(800, 600));

        jScrollPane1.setViewportView(jTextPane1);

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 18));
        jLabel1.setText("Geração de Árvore Geradora Mínima");

        labelAlgoritmo.setText("Método de Geração:");

        labelGrauMaximo.setText("Grau Máximo:");

        labelQtdArvores.setText("Quant. de Árvores:");

        labelCustoMaximo.setText("Custo Máximo (Dmax):");

        botaoGerar.setAction(new GerarRelatorioAction());
        botaoGerar.setText("Gerar");
        botaoGerar.setEnabled(true);

        labelResultado.setText("Resultado:");

        botaoExibir.setAction(new ExibirAGM());
        botaoExibir.setText("Exibir");
        botaoExibir.setEnabled(true);

        comAlgoritmo.addItem("Kruskal");
        comAlgoritmo.addItem("Prim");
        comAlgoritmo.addItem("Boruvka");
        comAlgoritmo.addItem("Las Vegas");
        comAlgoritmo.addItem("Busca Tabu");
        comAlgoritmo.addItem("Branch and Bound");
        comAlgoritmo.addItem("Exaustiva");
        comAlgoritmo.addItem("Aleatorio");
        
        //tfGrauMaximo.setVisible(false);
        //tdQtdArvores.setVisible(false);
        //tfCustoMaximo.setVisible(false);

        //labelGrauMaximo.setVisible(false);
        //labelQtdArvores.setVisible(false);
        //labelCustoMaximo.setVisible(false);


        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel1)
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(labelAlgoritmo)
                                            .addComponent(labelGrauMaximo))
                                        .addGap(53, 53, 53)
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                            .addComponent(tfCustoMaximo, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 201, Short.MAX_VALUE)
                                            .addComponent(tdQtdArvores, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 201, Short.MAX_VALUE)
                                            .addComponent(tfGrauMaximo, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 201, Short.MAX_VALUE)
                                            .addComponent(comAlgoritmo, 0, 201, Short.MAX_VALUE))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                                .addGap(34, 34, 34))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(labelQtdArvores)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(labelCustoMaximo)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(botaoGerar)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(botaoExibir)
                        .addGap(22, 22, 22)))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(labelResultado)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 395, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(41, 41, 41))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(11, 11, 11)
                .addComponent(jLabel1)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(32, 32, 32)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(labelAlgoritmo)
                            .addComponent(comAlgoritmo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(labelGrauMaximo)
                            .addComponent(tfGrauMaximo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(labelQtdArvores)
                            .addComponent(tdQtdArvores, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(labelCustoMaximo)
                            .addComponent(tfCustoMaximo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(107, 107, 107)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(botaoGerar)
                            .addComponent(botaoExibir)))
                    .addGroup(layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(labelResultado)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 442, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(95, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton botaoExibir;
    private javax.swing.JButton botaoGerar;
    private javax.swing.JComboBox comAlgoritmo;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextPane jTextPane1;
    private javax.swing.JLabel labelAlgoritmo;
    private javax.swing.JLabel labelCustoMaximo;
    private javax.swing.JLabel labelGrauMaximo;
    private javax.swing.JLabel labelQtdArvores;
    private javax.swing.JLabel labelResultado;
    private javax.swing.JTextField tdQtdArvores;
    private javax.swing.JTextField tfCustoMaximo;
    private javax.swing.JTextField tfGrauMaximo;
    // End of variables declaration//GEN-END:variables

    public JComboBox getComboAlgoritmo() {
    	return comAlgoritmo;
    }

    public JTextPane getTextPane() {
    	return jTextPane1;
    }

    public int getGrauMaximo() {
    	String grau = tfGrauMaximo.getText();
    	int result = GeradorArvoreMinima.ILIMITADO;
   
    	if(grau != null && grau.length()>0) {
    		result = Integer.parseInt(grau);
    	}
    	return result;
    }

    public int getQtdArvoreMaximo() {
    	String qtd = tdQtdArvores.getText();
    	int result = 1;
   
    	if(qtd != null && qtd.length()>0) {
    		result = Integer.parseInt(qtd);
    	}
    	return result;
    }

	public double getCustoMaximo() {
    	String custo = tfCustoMaximo.getText();
    	double result = GeradorArvoreMinima.ILIMITADO;
   
    	if(custo != null && custo.length()>0) {
    		result = Double.parseDouble(custo);
    	}
    	return result;
	}

	public JButton getBotaoGerar() {
		return botaoGerar;
	}
}
